package controllers

import (
	"strings"

	"git.oschina.net/tinkler/for_kmjxc/models/km"
)

// Operations about Supcusts
type SupcustController struct {
	HelperController
}

// @Title GetAll
// @Description get all suppliers of kmjxc]
// @Success 200	{object}	models.km.BiTSupcustInfo
// @router / [get]
func (s *SupcustController) GetAll() {
	s.Data[`json`] = km.GetBiTSupcustInfo("%")
	s.ServeAPI()
}

// @Title Get
// @Description get supplier by no
// @Param   no  path    string  true    "The supcust no"
// @Success 200 {object} models.km.BiTSupcustInfo
// @Failure 403 body is empty
// @router /:no [get]
func (s *SupcustController) Get() {
	no := s.GetString(":no")
	if supNo := strings.Replace(no, " ", "", -1); supNo != "" {
		s.Data[`json`] = km.GetBiTSupcustInfo(supNo)
	}
	s.ServeAPI()
}
